package cn.hdu.liang.ch2;

//代码清单2-4 虚拟机栈示例代码 TestJVMStack1
public class TestJVMStack1 {
    private int count = 0;

    //没有出口的递归函数
    public void recursion(long a, long b, long c) throws InterruptedException {
        long d = 11, e = 22, f = 32;
        count++;//每次调用深度加1
        recursion(a, b, c); //递归
    }

    public void testStack() {
        try {
            recursion(1L, 2L, 3L);
        } catch(Throwable e) {
            System.out.println("deep of stack is " + count); //打印栈溢出的深度
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        TestJVMStack1 ts = new TestJVMStack1();
        ts.testStack();
    }
}
